/*
 * Copyright (C) 2012 Rayworks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.spzone.android.ctrl;

import com.spzone.android.ctrl.ScrollButton.OnButtonSwitched;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.Toast;

public class ScrollButtonDemoActivity extends Activity implements OnButtonSwitched {
    private ScrollButton mBtn;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        mBtn = (ScrollButton)findViewById(R.id.scroll_button);
        mBtn.setButtonSwitchListener(this);
    }

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		return mBtn.onTouchEvent(event);
	}
	
	@Override
	public void onDetachedFromWindow() {
		mBtn.setButtonSwitchListener(null);
		super.onDetachedFromWindow();
	}

	@Override
	public void onSwitch(int sideId) {
		if(sideId == 0){
			Toast.makeText(this, "Left", Toast.LENGTH_SHORT).show();
		}else{
			Toast.makeText(this, "Right", Toast.LENGTH_SHORT).show();
		}		
	}    
}